﻿#include "app.h"

#include <stdlib.h>


#include "page_1.h"
#include "calendar.h"
#include "../LvglPlatform/lvgl/examples/lv_examples.h"
#include "pagemanager/pm.h"
static lv_obj_t *page_1;

void test_helloworld(lv_obj_t* page)
{
    lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
    /*Create a white label, set its text and align it to the center*/
    lv_obj_t* label = lv_label_create(lv_screen_active());
    lv_label_set_text(label, "Hello world");
    lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
    lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
}
void test_helloworld_unload(lv_obj_t* page)
{

}
lv_pm_open_options_t options = {
    .animation = LV_PM_ANIMA_SLIDE
};
bool open = false;

void timer_cb(lv_timer_t* timer)
{
    if (open) {
        lv_pm_back();
        open = false;
    }
    else {
        lv_pm_open_page(1, &options);
        open = true;
    }
}

void app(){
	//page_1 = page_1_create();

	//lv_scr_load(page_1);
    //page_1 = lv_button_create(lv_screen_active());
    //test_helloworld();
    //calendar();
    lv_pm_init();

    lv_pm_page_t* page1 = lv_pm_create_page(0);
    page1->onLoad = test_helloworld;
    page1->unLoad = test_helloworld_unload;

    lv_pm_page_t* page2 = lv_pm_create_page(1);
    page2->onLoad = calendar;
    page2->unLoad = calendar_unload;

    lv_pm_open_page(0, &options);
    lv_timer_create(timer_cb, 1000, NULL);

}
